Release 10.1A: OpenEdge Data Management:
SQL Reference
Date-time literals
SQL supports special formats for literals to be used in conjunction with date-time data types. Basic predicates and the
VALUESclause ofINSERTstatements can specify date literals directly for comparison and insertion into tables. In other cases, you need to convert date literals to the appropriate date-time data type with theCAST,CONVERT, orTO_DATEscalar functions.Enclose date-time literals in single quotation marks ( ' ' ).
Notes
Date literals
A date literal specifies a day, month, and year using any of the following formats, enclosed in single quotation marks ( ' ' ).
This is the syntax for a date literal:
{ d 'yyyy-mm-dd' }A date literal enclosed in an escape clause is compatible with ODBC. Precede the literal string with an open brace (
Note: If you use the ODBC escape clause, you must specify the date using the format{) and a lowercased. End the literal with a close brace )}).yyyy-mm-dd.ddSpecifies the day of the month as a one– or two–digit number in the range
01 to 31.mmSpecifies the month value as a one– or two–digit number in the range
01 to 12.monSpecifies the first three characters of the name of the month in the range '
JAN' to 'DEC'.yySpecifies the last two digits of the year.
yyyySpecifies the year as a four–digit number.
ExamplesThe following example illustrates how to use the date literal format with an
INSERTstatement:
The
INSERTandSELECTstatements in the following example show some of the supported formats for date literals:
Time literals
Time literals specify an hour, minute, second, and millisecond, using the following format, enclosed in single quotation marks (' ' ).
This is the syntax for a time literal:
{ t 'hh:mi:ss' }A time literal enclosed in an escape clause is compatible with ODBC. Precede the literal string with an open brace (
Note: If you use the ODBC escape clause, you must specify the time using the format{) and a lowercaset. End the literal with a close brace (}).hh:mi:ss.hhSpecifies the hour value as a two-digit number in the range
00to23.miSpecifies the minute value as a two-digit number in the range
00to59.ssSpecifies the seconds value as a two-digit number in the range
00to59.mlsSpecifies the milliseconds value as a three-digit number in the range
Examples000to999.The following example illustrates how to use the time literal format with an
INSERTstatement:
The
INSERTstatements in the following example show some of the formats SQL will and will not accept for time literals:
The
SELECTstatement in the following example illustrates whichINSERTstatements successfully inserted a row:
Timestamp literals
Timestamp literals specify a date and a time separated by a space, enclosed in single quotation marks ( ' ' ).
This is the syntax for a timestamp literal:
{ ts 'yyyy-mm-dd hh:mi:ss' }A timestamp literal enclosed in an escape clause is compatible with ODBC. Precede the literal string with an open brace (
Note: If you use the ODBC escape clause, you must specify the timestamp using the format{) and a lowercasets. End the literal with a close brace (}). Note that braces are part of the syntax.yyyy-mm-dd hh:mi:ss.date_literalA date.
time_literalA time literal.
ExamplesThe following example is example illustrates how to
INSERTa timestamp literal into a column:
The following example illustrates a timestamp literal with the ODBC escape clause:
|
Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |